'use strict';
/**
 * 微信用户表
 */
module.exports = app => {
  const { STRING, UUID, NOW, DATE, UUIDV4, INTEGER } = app.Sequelize;
  const WxUser = app.model.define('WxUser', {
    id: {
      type: UUID,
      primaryKey: true,
      allowNull: false,
      defaultValue: UUIDV4,
      comment: '用户id'
    },
    userId: {
      type: STRING(36),
      allowNull: false,
      field: 'user_id',
      comment: '小程序id'
    },
    avatarUrl: {
      type: STRING(255),
      field: 'avatar_url',
      comment: '头像'
    },
    nickName: {
      type: STRING(36),
      field: 'nick_name',
      comment: '昵称'
    },
    gender: {
      type: INTEGER,
      comment: '0男，1女'
    },
    language: {
      type: STRING(10),
      comment: '语言'
    },
    openId: {
      type: STRING(255),
      field: 'open_id',
      comment: 'openId'
    },
    province: {
      type: STRING(10),
      comment: '省份'
    },
    city: {
      type: STRING(10),
      field: 'city',
      comment: '城市'
    },
    country: {
      type: STRING(10),
      field: 'country',
      comment: '地区'
    },
    createDate: {
      type: DATE,
      defaultValue: NOW,
      field: 'create_date',
      comment: '创建时间'
    },
    updateDate: {
      type: DATE,
      defaultValue: NOW,
      field: 'update_date',
      comment: '更新时间'
    }
  }, {
    // 去除createAt，updateAt
    timestamps: false,
    // 实例对应的表名
    tableName: 'wx_user',
    // 将createdAt对应到数据库的created_at字段
    createdAt: 'create_date',
    // 将updatedAt对应到数据库的updated_at字段
    updatedAt: 'updated_date'
  });

  WxUser.associate = function () {
  }

  return WxUser;
};